package org.whh.client;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.whh.domain.LoginUser;
import org.whh.util.AjaxResult;
@Slf4j
@Component
public class AuthClientFallbackFactory implements FallbackFactory<AuthClient> {

    @Override
    public AuthClient create(Throwable throwable) {
        return new AuthClient() {
            @Override
            public AjaxResult addOrUpdate(LoginUser loginUser) {
                log.error("远程调用失败,被降级了");
                return AjaxResult.me().setSuccess(false).setMessage(throwable.getMessage());
            }
        };
    }
}
